package org.shushan.web.demo.service.impl;

import org.shushan.framework.core.datasource.DynamicDs;
import org.shushan.framework.mybatis.service.MybatisPlusServiceImpl;
import org.shushan.web.demo.entity.MybatisTest;
import org.shushan.web.demo.mapper.MybatisTestMapper;
import org.shushan.web.demo.request.MybatisTestDto;
import org.shushan.web.demo.request.MybatisTestPage;
import org.shushan.web.demo.response.MybatisTestVo;
import org.shushan.web.demo.service.MybatisTestService;
import org.springframework.cache.annotation.CacheEvict;
import org.springframework.cache.annotation.Cacheable;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.lang.reflect.Method;
import java.util.List;
import java.util.Objects;

/**
 * (TUser)表服务实现类
 *
 * @author zhigang.li
 * @email 2429967859@qq.com
 * @since 2023-09-16 22:25:41
 */
@Service("mybatisTestService")
public class MybatisTestServiceImpl
        extends MybatisPlusServiceImpl<MybatisTestPage, MybatisTestDto, MybatisTestVo, Long, MybatisTest, MybatisTestMapper>
        implements MybatisTestService{
//        implements MybatisTestService,CudCacheAdapterService<MybatisTestPage, MybatisTestDto, MybatisTestVo, Long, MybatisTest>  {
//        implements MybatisTestService,BaseCacheService {

//    @Bean
//    @Primary
//    public ServiceIdKeyGenerator serviceIdKeyGenerator() {
//        return new ServiceIdKeyGenerator();
//    }

    @Resource
    private MybatisTestMapper tUserMapper;

    @Override
    @DynamicDs
//    @Cacheable(cacheNames ="TUserServiceImpl", keyGenerator = BaseCacheService.SERVICE_KEY_GENERATOR)
    public MybatisTestVo get(Long id) {
//        MybatisTestVo mybatisTestVo = CudCacheAdapterService.super.get(id);
//        return mybatisTestVo;
        System.out.println("MybatisTestServiceImpl.get");
        return super.get(id);
    }


    @Override
    public List<MybatisTestVo> doList(MybatisTestPage request) {
        for (Method method : this.getClass().getMethods()) {
            if (Objects.nonNull(method.getAnnotation(Cacheable.class)) || Objects.nonNull(method.getAnnotation(CacheEvict.class))) {
                System.out.println("11111111111111111111111111111111");
            }
        }
        return super.doList(request);
    }
}
